package datastructure.tree;

/**
 * Maximum Height (Depth) of a Binary Tree
 * 
 * @author Lei
 */
public class MaxHeight {

    public static int maxHeight(TreeNode root) {
        if (root == null) {
            return 0;
        }

        int leftHeight = maxHeight(root.left);
        int rightHeight = maxHeight(root.right);

        return leftHeight > rightHeight ? leftHeight + 1 : rightHeight + 1;
    }

}
